/*nomutex.c*/  
#include <pthread.h>  
#include <stdio.h>  
#include <unistd.h>  
#include <errno.h>  
#include <stdlib.h>  
#include <string.h>  

char str[] = "abcdefghijklmnopqrstuvwxyz123456789";  
int index2 = 0;  

void *t1_exe(void *arg) {  
    while (index2 < strlen(str) - 1) {  
        printf("The %dth element of array is %c\n", index2, str[index2]);  
        sleep(1);  
        index2++;  
    }  
    return NULL;  // 补充线程函数返回值  
}  

int main() {  
    pthread_t pid1, pid2;  
    int error1, error2;  
    error1 = pthread_create(&pid1, NULL, t1_exe, NULL);  
    error2 = pthread_create(&pid2, NULL, t1_exe, NULL);  
    if (error1 != 0 || error2 != 0) {  
        printf("pthread_create failed ");  
        return -1;  // 规范错误处理返回值  
    }  
    pthread_join(pid1, NULL);  
    pthread_join(pid2, NULL);  
    return 0;  // 主函数规范返回值  
}  
